﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;

public partial class Information_BasicInformation_BasicInformationEdit : BasePage
{
    BasicInformationBO bbo = new BasicInformationBO();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if(Request.QueryString["ID"]!=null)
            {
                BasicInformation b = bbo.GetModel(int.Parse(Request.QueryString["id"].ToString()),CurrentUserInfo.MID);
                if (b != null)
                {
                    content1.InnerText = b.Explain;
                }

            }
        }
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["ID"] != null)
        {
            BasicInformation b = bbo.GetModel(int.Parse(Request.QueryString["id"].ToString()),CurrentUserInfo.MID);
            if (b != null)
            {
                b.Explain = content1.InnerText;
                b.CreateDate = DateTime.Now;
                int num = bbo.Update(b);
                if (num > 0)
                {
                    AlertMessage("修改成功");
                }
            }
            else
            {
                b = new BasicInformation();
                b.Explain = content1.InnerText;
                b.CreateDate = DateTime.Now;
                b.MID = CurrentUserInfo.MID;
                b.Type = int.Parse(Request.QueryString["id"].ToString());
                int num = bbo.Add(b);
                if (num > 0)
                {
                    AlertMessage("修改成功");
                }
            }

        }
    }
}